package client_proxy

import (
	"go_rpc/gorpc/handler"
	"net/rpc"
)

type HelloServiceStub struct {
	*rpc.Client
}

// 在go中没有类对象，就没有构造器初始化，需要Newxxx

func NewHelloServiceClient(protocol, address string) *HelloServiceStub {
	client, err := rpc.Dial(protocol, address)
	if err != nil {
		panic("拨号失败")
	}
	return &HelloServiceStub{client}
}

func (c *HelloServiceStub) Hello(msg string, reply *string) error {
	err := c.Call(handler.HelloServiceName+".Hello", msg, reply)
	if err != nil {
		return err
	}
	return nil
}
